
$('.btn-submit').on('click',function(){
     var username = $('#inputUsername').val().trim();
     var password = $('#inputPassword').val().trim();

     if(!username){
        showMsg($('.error-info'),'Please input username');
        return
     }
    
     if(!password){
        showMsg($('.error-info'),'Please input password');
        return
     }

     $.ajax({
         url:adminUrl,
         type:'POST',
         headers: {
           'X-CSRF-TOKEN':$('meta[name="csrf-token"]').attr('content')
         },
         data:{
             name:username,
             password:password,
             role:'admin'
         }
     }).done(function(res){
         if(res.success){
            window.location.href=adminUrl;
         }else{
            showMsg($('.error-info'),res.msg);
         }
     }).fail(function(xhr){
         showMsg($('.error-info'),'Server error');
         console.log(xhr)
     });

});